#-*- coding: utf-8-*-

#Autor Pedro Lopes


import math

x = 23.4
s1 = "raiz quadrada"
y = 255
s2 = "Temos {:^40} de x = {valor:2.4f}".format(s1, valor = x)
s2 += " e y = 0x{yy:X}".format(yy=y)
s2 += "\nA percentagem = {0:2.1%}".format(34/100.0)

print s2


f = open("teste.txt","w")
s = "treta"
for k in range(10):
    f.write(s);
    f.write("\n")
f.close()

f = open("teste.txt", "r")
f.seek(5)
print f.tell()
x = f.read(10)
print x
c = 0
for line in f:
    print "{0}".format(c), line
    c +=1
f.close()
with open("teste.txt", "r") as f:
    x = f.readline()
    if x == 'treta\n':
        print "voila"
          
